/*
 * Copyright 2012-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.boot.autoconfigure.sql.init;

import java.nio.charset.Charset;
import java.util.List;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.sql.init.DatabaseInitializationMode;

/**
 * 用于初始化 SQL 数据库的 {@link ConfigurationProperties 配置属性}。
 *
 * @author Andy Wilkinson
 * @since 2.5.0
 */
@ConfigurationProperties("spring.sql.init")
public class SqlInitializationProperties {

	/**
	 * 要应用到数据库的架构（DDL）脚本的位置列表。
	 */
	private List<String> schemaLocations;

	/**
	 * 要应用到数据库的数据（DML）脚本的位置列表。
	 */
	private List<String> dataLocations;

	/**
	 * 用于默认架构或数据脚本位置的数据库平台，
	 * 如 schema-${platform}.sql 和 data-${platform}.sql。
	 */
	private String platform = "all";

	/**
	 * 执行初始化脚本时使用的数据库用户名（如果不同）。
	 */
	private String username;

	/**
	 * 执行初始化脚本时使用的数据库密码（如果不同）。
	 */
	private String password;

	/**
	 * 出错时是否继续初始化。
	 */
	private boolean continueOnError = false;

	/**
	 * 架构和数据脚本中的语句分隔符。
	 */
	private String separator = ";";

	/**
	 * 架构和数据脚本的编码格式。
	 */
	private Charset encoding;

	/**
	 * 判断是否应执行初始化时所用的模式。
	 */
	private DatabaseInitializationMode mode = DatabaseInitializationMode.EMBEDDED;

	public List<String> getSchemaLocations() {
		return this.schemaLocations;
	}

	public void setSchemaLocations(List<String> schemaLocations) {
		this.schemaLocations = schemaLocations;
	}

	public List<String> getDataLocations() {
		return this.dataLocations;
	}

	public void setDataLocations(List<String> dataLocations) {
		this.dataLocations = dataLocations;
	}

	public String getPlatform() {
		return this.platform;
	}

	public void setPlatform(String platform) {
		this.platform = platform;
	}

	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public boolean isContinueOnError() {
		return this.continueOnError;
	}

	public void setContinueOnError(boolean continueOnError) {
		this.continueOnError = continueOnError;
	}

	public String getSeparator() {
		return this.separator;
	}

	public void setSeparator(String separator) {
		this.separator = separator;
	}

	public Charset getEncoding() {
		return this.encoding;
	}

	public void setEncoding(Charset encoding) {
		this.encoding = encoding;
	}

	public DatabaseInitializationMode getMode() {
		return this.mode;
	}

	public void setMode(DatabaseInitializationMode mode) {
		this.mode = mode;
	}

}
